#include <algorithm>
#include <cstdio>
#include <tuple>
#include <vector>
constexpr int MaxN = 5e5 + 5;
int n, m;
int p[MaxN];
bool v[MaxN];
std::vector<std::tuple<int, int>> rules;
int main()
{
    freopen("gonna.in", "r", stdin);
    freopen("gonna.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &p[i]);
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        rules.push_back({l, r});
    }
    if (n <= 20)
    {
        long long answer = 0x7f7f7f7f7f7f7f7f;
        for (int j = 0; j < (1 << n); j++)
        {
            long long temp = 0;
            for (int i = 1; i <= n; i++)
            {
                if ((j >> (i - 1)) & 1)
                {
                    temp += p[i];
                    v[i] = true;
                }
                else
                {
                    v[i] = false;
                }
            }
            bool success = true;
            for (auto k : rules)
            {
                int l, r;
                std::tie(l, r) = k;
                bool f = false;
                for (int i = l; i <= r; i++)
                {
                    if (v[i])
                    {
                        f = true;
                        break;
                    }
                }
                if (!f)
                {
                    success = false;
                    break;
                }
            }
            if (success)
            {
                answer = std::min(answer, temp);
            }
        }
        printf("%lld\n", answer);
        return 0;
    }
    long long answer = 0;
    for (auto k : rules)
    {
        int l, r;
        std::tie(l, r) = k;
        int x = 0x3f3f3f3f;
        for (int i = l; i <= r; i++)
        {
            x = std::min(x, p[i]);
        }
        answer += x;
    }
    return 0;
}